﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_Admin_XoaSanPhamDang1 : System.Web.UI.Page
{
    string MaSP = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            btnXoa1.Attributes["OnClick"] = "return confirm('Bạn thật sự muốn xóa');";
        }
        pnlSanPham.Visible = false;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        MaSP = txtMaSanPham.Text;
        DataDSTableAdapters.SANPHAMTableAdapter spadapter = new DataDSTableAdapters.SANPHAMTableAdapter();
        DataDS.SANPHAMDataTable sptable = spadapter.SANPHAM_LayTheoMaSP(MaSP);
        if (sptable.Rows.Count == 0)
        {
            Response.Write("Không tồn tại!");
        }
        else
        {
            imgHinhAnh.ImageUrl = sptable.Rows[0]["HinhAnh"].ToString();
            lblTenSanPham.Text = sptable.Rows[0]["TenSP"].ToString();
            lblMoTa.Text = sptable.Rows[0]["MoTa"].ToString();
            lblNhaSanXuat.Text = sptable.Rows[0]["NhaSanXuat"].ToString();
            pnlSanPham.Visible = true;
        }
       // ModalPopupExtender1.Show();
    }

    protected void btnXoa1_Click(object sender, EventArgs e)
    {
        string chuoi = txtMaSanPham.Text;
        DataDSTableAdapters.SANPHAMTableAdapter spadapter = new DataDSTableAdapters.SANPHAMTableAdapter();
        int? kq = 0;
        spadapter.SANPHAM_XoaTheoMaSP(chuoi, ref kq);
        if (kq == 0)
            modelXoaThanhCong.Show();
        else
            modelKhongThanhCong.Show();

       //  Response.Redirect("Admin_XoaSanPhamDang1.aspx");
       
    }
}
